<?php

namespace common\components;

use Yii;

class Oauth2{

    public $storage = null;
    public $server = null;

    public static function getStorage(){
        $mysql = Yii::$app->components["db"];
        return new \OAuth2\Storage\Pdo(array('dsn' => $mysql["dsn"], 'username'=> $mysql["username"], 'password'=> $mysql["password"]));
    }

    public static function getServer(){
        \OAuth2\Autoloader::register();
        $storage = self::getStorage();
        return new \OAuth2\Server($storage);
    }

}
